package aufg3;

public class Uniform extends RandVar {

	public double calculateMean() {
		super.reset();
		super.mean = (super.stdRNG.getMaxRange() + super.stdRNG.getMinRange()) / 2;

		return super.mean;
	}

	private double[] getRV(int sizeOfArray) {
		super.randomNumbers = new double[sizeOfArray];
		for (int i = 0; i < super.randomNumbers.length; i++) {
			super.randomNumbers[i] = super.stdRNG.getNextRandomNumberWithRange(
					0, 1);
			// this.stdRNG.setSeed(i);
		}
		return super.randomNumbers;
	}
	
	public double calculateVariance() {
		super.reset();
		double bMINUSa = (super.stdRNG.getMaxRange() - super.stdRNG.getMinRange());
		super.variance = super.quadrat(bMINUSa) /12;
		return super.variance;
	}
	
	//Wikipedia, ist aber das gleiche ergebnis wie SA/E
	@Override
	public double calculateCoefﬁcientOfVariation() {
		reset();
		double bMINUSa = (super.stdRNG.getMaxRange() - super.stdRNG.getMinRange());
		double bPLUSa = (super.stdRNG.getMaxRange() + super.stdRNG.getMinRange());
		
		super.coefﬁcientOfVariation = 1/Math.sqrt(3) *  (bMINUSa / bPLUSa);
		
		return super.coefﬁcientOfVariation;
	}
	
	
	public static void main(String[] args) {
		Uniform u = new Uniform();
		
		double[] rv = u.getRV(1110);
		System.out.println(u.numberArrayToString());
		System.out.println(u.calculateMean());
		System.out.println(u.calculateVariance());
		System.out.println(u.calculateCoefﬁcientOfVariation());
		
	}

}
